/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.DigitalInput;

/**
 * BCD switch, has two connecters on it and thus handles modes 1 through 4
 * @author robert
 */
public class PhoenixBcd {
    /// BCD pin 0
    public DigitalInput bcd1;
    /// BCD pin 1
    public DigitalInput bcd2;
    /// previous BCD value
    int previousValue;

    /**
     * standard BCD constructor
     * @param switchChannel1 first pin
     * @param switchChannel2 second pin
     */
    public PhoenixBcd (DigitalInput bcd1, DigitalInput bcd2) {
        this.bcd1 = bcd1;
        this.bcd2 = bcd2;
    }

    /**
     * gets BCD value
     * @return bcd value
     */
    public int get() {
        int v = 0;
        if(!bcd1.get())
            v += 1;
        if(!bcd2.get())
            v += 2;
        return v;
    }

    /**
     * returns new value if different, -1 if otherwise
     * @return BCD value
     */
    public int getIfDifferent() {
        int currentValue = this.get();

        if(currentValue != previousValue) {
            return currentValue;
        } else {
            return -1;
        }
    }
}
